import { Component, OnInit,ViewContainerRef } from '@angular/core';
import { flyInOut } from "../utils/anim";
import { ArticleListService } from './article-list/shared/article-list.service';
import {LoadingService} from "../common/loading/loading.service";
import {ArticleWriteComponent} from "./article-write/article-write.component";
@Component({
	selector: 'article',
	templateUrl: 'article.component.html',
	animations: [
		flyInOut
	],
	providers: [ArticleListService,LoadingService],
	styleUrls:["article.component.scss"]
})

export class ArticleComponent implements OnInit {
	//分页组件信息
	public maxSize:number = 5;
	public bigTotalItems:number = 175;
	public bigCurrentPage:number = 1;
	public numPages:number = 0;
	
	artiveImage:any=[{
	 	image: `http://valor-software.com/ng2-bootstrap/assets/images/nature/5.jpg`,
	 	text: "qwer"
	 },
	 {
	 	image: `http://valor-software.com/ng2-bootstrap/assets/images/nature/5.jpg`,
	 	text: "qwer"
	 },
	 {
	 	image: `http://valor-software.com/ng2-bootstrap/assets/images/nature/5.jpg`,
	 	text: "qwer"
	 }]

	 searchType:string="123";
	 
	 articleList:any;

	 constructor(private articleListService: ArticleListService,
	  private viewContainer: ViewContainerRef,
     private  loadService: LoadingService) {
		 loadService.defaultViewContainerRef = viewContainer;
	}
	ngOnInit() { 
		//  this.articleListService.getList().then(
		// 	 data=>console.log("data"+data)
		//  ).catch(err=>alert(err));
	}
	 searchList(list:any){
		   console.log("传入搜索类型" + list);
		 	this.articleList=list;
	 }
	loadingShow(isShow:boolean){
		if(isShow){
			this.loadService.show();
		}else{
			this.loadService.hide();
		}
	}	
 //更改
  public pageChanged(event:any):void {
    console.log('Page changed to: ' + event.page);
    console.log('Number items per page: ' + event.itemsPerPage);
  }
  onDestroy(){
	  this.loadService.destroy();
  }
}